package After826.ChatRoom;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class TestSockServer {
    public static void main(String[] args) {
        InputStream in = null;
        OutputStream out = null;
        try{
            ServerSocket s = new ServerSocket(8888);
            Socket s1 = s.accept();
            in = s1.getInputStream(); 
            out = s1.getOutputStream();
            DataOutputStream dos = new DataOutputStream(out);
            DataInputStream dis = new DataInputStream(in);
            String str = null;
      if((str = dis.readUTF())!= null) {
            System.out.println("客户端输入内容：" + str);
            System.out.println("客户端IP: " + s1.getInetAddress().getHostAddress());
            System.out.println("客户端端口号: " + s1.getPort());
        }
        dos.writeUTF("服务器端反馈客户端！"); 
        dis.close();
        dos.close();
        s1.close();
        }catch(IOException e){
            e.printStackTrace();
        }
    }
}